import 'package:get_it/get_it.dart';
import 'package:injectable/injectable.dart';
import 'package:stacked_services/stacked_services.dart';

import 'injection.config.dart';

/// GetIt 实例
final getIt = GetIt.instance;

/// 初始化依赖注入
/// 注意：需要先运行 `flutter pub run build_runner build` 生成 injection.config.dart
@InjectableInit(
  initializerName: 'init',
  preferRelativeImports: true,
  asExtension: true,
)
Future<void> configureDependencies() async {
  // 注册 stacked_services
  getIt.registerSingleton(NavigationService());
  getIt.registerSingleton(DialogService());
  getIt.registerSingleton(BottomSheetService());
  getIt.registerSingleton(SnackbarService());

  // 初始化其他依赖
  await getIt.init();
}
